﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls;

public partial class Main_Inventory_TransFormatView : System.Web.UI.Page
{
    Datautility DU = new Datautility();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["msg"] != null)
        {
            if (Request.QueryString["msg"].ToString().Equals("u"))
            {
                lblMsg.Attributes.Remove("class");
                lblMsg.Attributes.Add("class", "true");
                lblMsg.Text = "Updated successfully...";
            }
        }
        if (!IsPostBack)
        {
            BindGrid();
        }
       
    }
    protected void BindGrid()
    {
        try
        {
            DataTable dt = DU.getdatausingprocedure("USP_IVR_GET_ALLTRANFORMATS");
            GrdDisplay.DataSource = dt;
            GrdDisplay.DataBind();
            custPager.TotalPages = 2;
        }
        catch (Exception se)
        {
            lblMsg.Attributes.Remove("class");
            lblMsg.Attributes.Add("class", "false");
            lblMsg.Text = se.Message;
        }
    }
    protected void custPager_PageChanged(object sender, CustomPageChangeArgs e)
    {
        GrdDisplay.PageSize = e.CurrentPageSize;
        GrdDisplay.PageIndex = e.CurrentPageNumber;
        BindGrid();
    }
    protected void GrdDisplay_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GrdDisplay.PageIndex = e.NewPageIndex;
        BindGrid();
    }
    protected void GrdDisplay_SelectedIndexChanged(object sender, EventArgs e)
    {
       string tfoid=GrdDisplay.DataKeys[GrdDisplay.SelectedIndex].Values[0].ToString();
       string trantypeid = GrdDisplay.DataKeys[GrdDisplay.SelectedIndex].Values[1].ToString();
       string trantypename = GrdDisplay.DataKeys[GrdDisplay.SelectedIndex].Values[2].ToString();
       Response.Redirect("TransFormatEdit.aspx?tfoid=" + tfoid + "&trantypeid=" + trantypeid + "&trantypename="+trantypename);
    }
   
    public bool SetControlVisible(int count)
    {
        if (count > 0)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    protected void GrdDisplay_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("DeleteRow"))
        {
            string tfoid=e.CommandArgument.ToString();
            //lblMsg.Attributes.Remove("class");
            //lblMsg.Attributes.Add("class", "true");
            //lblMsg.Text = "Transaction format deleted successfully...";
        }
    }
    protected void GrdDisplay_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType != DataControlRowType.Pager)
        {
            if (e.Row.RowState == DataControlRowState.Alternate)
            {
                e.Row.Attributes.Add("onmouseover", "this.className='rowhover'");
                e.Row.Attributes.Add("onmouseout", "this.className='gridview_alternate'");
                //e.Row.Attributes.Add("onclick", "this.className='rowselected'");
            }
            else if (e.Row.RowState == DataControlRowState.Normal)
            {
                e.Row.Attributes.Add("onmouseover", "this.className='rowhover'");
                e.Row.Attributes.Add("onmouseout", "this.className='gridviewitem'");
                //e.Row.Attributes.Add("onclick", "this.className='rowselected'");
            }
        }
    }
}
